// /cloudfunctions/deleteUser/main.js
'use strict';
const db = uniCloud.database();

exports.main = async (event, context) => {
    const { _id } = event;
    if (!_id) return { code: 400, msg: '缺少用户ID' };
    
    const res = await db.collection('users').doc(_id).remove();
    if (res.affectedDocs === 0) {
        return { code: 404, msg: '用户不存在' };
    }
    return { code: 200, msg: '删除成功' };
};